<template>
	<view class="content">
		<uni-nav-bar title="我的图册" leftIcon="back" backgroundColor="#4a87b6" color="white" @clickLeft="back()"></uni-nav-bar>
		<div v-for="item in data">
			<uni-section :title="item.createTime.substr(0, 10)" type="line">
				<uni-card :cover="item.imgUrl" >
					<image slot='cover' style="width: 100%;" :src="item.imgUrl"></image>
					<text class="uni-body">{{item.desc}}</text>	
				</uni-card>
			</uni-section>
		</div>
		<div @click="nextPage()" class="message">
			{{message}}
		</div>
	</view>
</template>

<script>
	import {queryById} from '@/api/sd-img.js';
	export default {
		data() {
			return {
				message:"加载更多...",
				id:"",
				token:"",
				currentPage:1,
				size:"",
				title:"2024-04-21",
				cover:"https://mp-6f81e20c-45ed-420c-8b9c-c84e21bce18b.cdn.bspapp.com/sd/titleImg/1713685883771.png",
				desc:"第一幅图描绘了一个清澈的夜空，星星点点的繁星装饰着整个天空，一个人躺在阳台上，仰望星空，感受着宇宙的神秘。第二幅图则展现了一个宁静的午后，阳台上摆放着清茶和好书，轻柔的音乐在耳边响起，营造出一种舒适放松的氛围。",
				data:[
					
				]
				
			};
		},
		methods:{
			//返回
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			//触底事件
			onReachBottom() {
				this.nextPage()
			},
			getMessage(){
				this.id=uni.getStorageSync("id"),
				this.token=uni.getStorageSync("authorization")
			},
			nextPage(){
				if(this.currentPage>=this.size){
					this.message = "没有更多了"
				}else{
					this.currentPage +=1
					this.getData()
				}
				
			},
			//获取数据
			getData(){
				queryById({
					token:this.token,
					authorId:this.id,
					currentPage:this.currentPage
				}).then(res=>{
					this.data = [...this.data,...res.data.data.records]
					this.size = res.data.data.pages
					console.log(this.data)
					console.log(this.size)
				})
			}
		},
		onLoad() {
			this.getMessage()
			this.getData()
		}
	}
</script>

<style lang="scss">
.content{
	text-align: center;
	padding-bottom: 20rpx;
	.message{
		color: gray;
		font-size:30rpx;
	}
}
</style>
